/*
 * key.h
 *
 * key driver for I/O keys.
 *
 * Copyright (C) 2022 Mi Micro Well TECH, Inc.
 * Subject to the GNU Public License, version 2.
 *
 * Author: guoming<guoming@microwell.net>
 */
#ifndef _KEY_H_
#define _KEY_H_

#include "mcu_regs.h"
#include "config.h"

/*=============================================================================
 *                               Key config
 *===========================================================================*/
/**
 *  I/O is low while key pressed 
 *  low active, pull up
 *  high active, pull down
 * */

#define CONFIG_KEY_ACTIVE_LOW       (0)

/*
 * KEY I/O definition, for example:
 * 0x01 stands for P01, 0x13 stands for P13.
 * 
 */

#define CONFIG_KEY_IO_STATUS        (_P04)

/* short & long pressed count in 10ms */
#define CONFIG_KEY_SHORT_PRESS_CNT  (110)
#define CONFIG_KEY_2S_PRESS_CNT     (200)
#define CONFIG_KEY_5S_PRESS_CNT     (500)
#define CONFIG_KEY_8S_PRESS_CNT     (800)
#define CONFIG_KEY_15S_PRESS_CNT    (1500)
#define CONFIG_KEY_LONG_PRESS_CNT   (1000)
#define CONFIG_KEY_3S_PRESS_CNT     (300)
/*=============================================================================
 *                             Key config end
 *===========================================================================*/

void key_init(void);
void key_handle_10ms(void);
#endif